<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>05_JS运算符</title>
</head>
<body>
<script>
  //1、算术运算符
  let a = 3;
  let b = 2;
  console.log(a + b);//5
  console.log(a - b);//1
  console.log(a * b);//6
  console.log(a / b);//1.5
  console.log(a % b);//1
  //2、比较运算符
  console.log(a > b);//true
  console.log(a < b);//false
  console.log(a >= b);//true
  console.log(a <= b);//false
  console.log(a == b);//false
  console.log(a != b);//true
  console.log('3' == 3);//true
  //如果比较运算符两侧都为字符串，则比较的是字符串的Unicode编码
  //'33311'.charCodeAt(4) 获取指定下标的字符的Unicode编码，默认取第一个字符的Unicode编码
  console.log('陈' > '杨');//true
  console.log('陈'.charCodeAt());//20013
  console.log('杨'.charCodeAt());//22269
  console.log('100863'.charCodeAt());//49
  console.log('100863'.charCodeAt(1));//48

  let a1 = 1;
  let b1 = true;
  //true 松散比较运算符，只比较值，不比较数据类型
  console.log(a1 == b1);
  //false 严格比较运算符，既比较值，也比较数据类型
  console.log(a1 === b1);

  let c = 0;
  console.log(c == 0 ? 'YES' : 'NO');//YES
  //=是赋值符号，先把0赋值给c，然后转为boolean类型，再判断
  console.log(c = 0 ? 'YES' : 'NO');//NO
</script>
</body>
</html>
